<?php
/**
 * 商城首页
 * author:ty
 * date:2017/08/22
 */
namespace App\Http\Controllers;

use App\Http\Models\User;
use Illuminate\Support\Facades\DB;

class IndexController extends Controller
{
    public function __construct()
    {
        $this->nav = '家具租赁';
    }

    public function index()
    {
        if(!session('user')){
            $this->user = '';
            $param = null;
        }else{
            $this->user = User::find(session('user')->id);
            $param['cart'] = CommonController::shopcart(session('user')->id);
        }
        $param['banner'] = DB::table('carousel')->where('carousel_status',1)->orderBy('updated_at','desc')->orderBy('carousel_status','desc')->paginate('3');
        $param['classify_lists'] = array(
            '7'=>'办公桌',
            '8'=>'办公椅',
            '9'=>'文件柜',
            '10'=>'配件'
        );

        return view('index',['user'=>$this->user,'param'=>$param,'nav'=>$this->nav]);
    }

    /**公司简介*/
    public function company_introduce()
    {
        if(!session('user')){
            $this->user = '';
            $param = null;
        }else{
            $this->user = User::find(session('user')->id);
            $param['cart'] = CommonController::shopcart(session('user')->id);
        }
        return view('link.company_introduce',['user'=>$this->user,'param'=>$param,'nav'=>'']);

    }

    /**链接部分加入我们*/
    public function join_us()
    {
        if(!session('user')){
            $this->user = '';
            $param = null;
        }else{
            $this->user = User::find(session('user')->id);
            $param['cart'] = CommonController::shopcart(session('user')->id);
        }
        return view('link.join_us',['user'=>$this->user,'param'=>$param,'nav'=>'']);
    }

    /**售后服务*/
    public function after_service()
    {
        if(!session('user')){
            $this->user = '';
            $param = null;
        }else{
            $this->user = User::find(session('user')->id);
            $param['cart'] = CommonController::shopcart(session('user')->id);
        }
        return view('link.after_service',['user'=>$this->user,'param'=>$param,'nav'=>'']);
    }

    /**租赁指南*/
    public function guide()
    {
        if(!session('user')){
            $this->user = '';
            $param = null;
        }else{
            $this->user = User::find(session('user')->id);
            $param['cart'] = CommonController::shopcart(session('user')->id);
        }
        return view('link.guide',['user'=>$this->user,'param'=>$param,'nav'=>'']);
    }

    /**支付方式*/
    public function pay_style()
    {
        if(!session('user')){
            $this->user = '';
            $param = null;
        }else{
            $this->user = User::find(session('user')->id);
            $param['cart'] = CommonController::shopcart(session('user')->id);
        }
        return view('link.pay_style',['user'=>$this->user,'param'=>$param,'nav'=>'']);
    }

    /**送货政策*/
    public function deliver_policy()
    {
        if(!session('user')){
            $this->user = '';
            $param = null;
        }else{
            $this->user = User::find(session('user')->id);
            $param['cart'] = CommonController::shopcart(session('user')->id);
        }
        return view('link.deliver_policy',['user'=>$this->user,'param'=>$param,'nav'=>'']);
    }
}
